﻿using Ymatou.Evaluate.Data.Operator;
using Ymatou.Evaluate.Data.Query;
using Ymatou.Evaluate.Entity;
using Ymatou.Evaluate.Seller.Model.ApiModel.Request.Opt;
using Ymatou.Evaluate.Seller.Model.ApiModel.Response.Opt;

namespace Ymatou.Evaluate.Service.Seller.Implement
{
    public class SellerOperatorService 
    {
        public EvaluateReplyResponse AddReply(EvaluateReplyRequest request)
        {
            var response = new EvaluateReplyResponse
            {
                IsSuccess = false,
                Msg = string.Empty
            };

            var exists = EvaluateQueryData.SellerProductEvalExists(request.SellerId, request.ProdEvalId);
            if (!exists)
            {
                response.Msg = "商品评价与买手不符或评价不存在";
                return response;
            }

            var result = new OperatorService().AddReply(new EvaluateReply
            {
                ProdEvalId = request.ProdEvalId,
                OrigReply = request.ReplyComments
            });
            response.IsSuccess = result;
            response.Msg = result ? "回复成功" : "回复失败";
            return response;
        }
    }
}
